<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <script type="text/javascript">
                /**
                 * 从 file 域获取 本地图片 url
                 */
            function getFileUrl(sourceId) {
                var url;
                if (navigator.userAgent.indexOf("MSIE")>=1) { // IE
                    url = document.getElementById(sourceId).value;
                    console.log("MSIE");
                } else if(navigator.userAgent.indexOf("Firefox")>0) { // Firefox
                    url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
                    console.log("Firefox");
                } else if(navigator.userAgent.indexOf("Chrome")>0) { // Chrome
                    url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
                    console.log("Chrome");
                }else{
                    url = document.getElementById(sourceId).value;
                    console.log("else");
                }
                console.log(url);
                return url;
            }
            
            
            //IOS
            function upLoadSfsb(userid){
                
                console.log('upLoadSfsb');
                var u = navigator.userAgent, app = navigator.appVersion;
                var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
                var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
                  if (isAndroid) {
                    //这个是安卓操作系统
                    console.log('isAndroid');
                    javascript:window.js.upLoadSfsb(userid);//android
                  }
                  if (isIOS) {
                  　　//这个是ios操作系统, 这句是为了兼容老版本
                    console.log('isIOS');
                    javascript:window.js.upLoadSfsb(userid);//isIOS
                  }
            }

            </script>
    </head>
    <body>
        <form action="">
            <input type="file" name="imgOne" id="imgOne" onchange="preImg(this.id,'imgPre');" />
            <input type="button" name="imgOne" id="imgOne" onclick="upLoadSfsb('101');" />
            <img id="imgPre" src="" width="300px" height="300px" style="display: block;" />
        </form>
    </body>
</html>
